<?php $menuHelper = Mage::helper('megamenu'); ?>
<?php $menuData = $menuHelper->getMenuData(); extract($menuData); ?>
<div class="header-wrapper">
<div class="main-nav">
    <div class="container">            
        <div class="menu-wrapper">
            <div class="menu-all-pages-container">
                <ul class="menu">
                    <?php echo $menuHelper->getMenuContent(); ?>
                </ul>
            </div>
        </div>
    </div>
</div>

</div>

<script type="text/javascript">
var SW_MENU_POPUP_WIDTH = <?php echo $_popupWidth; ?>;
jQuery(function($){
    $(document).ready(function(){
        $('.main-nav .menu').et_menu({
            type: "default",
            delayTime: <?php echo $menuHelper->getConfig('popup/popup_delay'); ?>
        });
<?php if($menuHelper->getConfig('popup/ajax_load_popups')): ?>
        url = "<?php echo Mage::getBaseUrl()."swmegamenu/index/showpopup" ?>";
        $(".main-nav ul.menu > li.menu-static-width, .main-nav ul.menu > li.menu-full-width, .main-nav ul.menu > li.menu-item").off("mouseover").on("mouseover",function(){
            if(!$(this).hasClass("ajax-loaded") && !$(this).hasClass("ajax-loading") && $(this).attr("data-id")) {
                var cur_menu_item = $(this);
                param = "?category_id="+$(this).attr("data-id");
                $(cur_menu_item).addClass("ajax-loading");
                $.ajax({
                    url: url+param,
                    dataType: 'json',
                    type: 'post',
                    success: function(data) {
                        $(cur_menu_item).removeClass("ajax-loading").addClass("ajax-loaded");
                        $(cur_menu_item).children(".nav-sublist-dropdown").children(".container").html(data['popup_content']).hide().fadeIn();
                    },
                    error: function(){
                        $(cur_menu_item).removeClass("ajax-loading");
                    }
                });
            }
        });
<?php endif; ?>
    });
});
</script>